#!/usr/bin/env python
# -*- coding: utf-8 -*-
#===============================================================================
# Copyright 2011 zod.yslin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
# Author: zod.yslin
# Email: 
# File Name: set.py
# Description: 
#   Set是简单对象的無序集合
# Edit History: 
#   2011-10-13    File created.
#===============================================================================
s = set([1,2,3])
print(1 in s)
#False 
# 可以使用copy函数来拷贝一个set：
old_set = set([1,2,3])
new_set = old_set.copy() 
# 可以使用add和remove来向set中添加或删除元素：
s = set([1,2,3])
s.add(4)
s.remove(1)
print(s)
#{2,3,4} 
#  可以使用&、|求两个set的交集、并集：
s1 = set([1,2,3])
s2 = set([2,4])
print(s1 & s2)
print(s1 | s2)
#{2}
#{1,2,3,4} 
